<template>
    <div class="photoList-container">
        <h3>{{photosList.name}}</h3>
        <p class="time">
            营业时间：{{photosList.businessHours}}
        </p>
        <hr>
        <div class="imgList">
            <img class="preview-img" v-for="(item, index) in list" :src="item.src" height="100"  @click="$preview.open(index,list)" :key="item.id">
        </div>

        <div class="content">
            {{photosList.address}}
        </div>
        <comment-Box :id="this.id" :catId="this.id"></comment-Box>
    </div>
</template>

<script>
    import comment from '..//subComponents/comment.vue';
    export default {
        data() {
            return {
                id: this.$route.params.id,
                photosList: [],
                limit: 10,
                list:[]
            }
        },
        created() {
            this.getPhotos();
            this.getImg();

        },
        methods: {
            getPhotos() {
                this.$http.get('categories/'+this.id+'/shops').then(result => {
                    if (result.status === 200) {
                        this.photosList = result.data[this.id];
                    } else {
                        Toast('网络较差，请稍候再试')
                    }
                })
            },
            getImg() {
                const data11 = {
                    _limit: this.limit,
                };
                this.$http.get('categories/'+this.id+'/shops',{params:data11}).then(result => {
                    if (result.status === 200) {
                        result.data.forEach(item =>{
                            item.src = item.images[0];
                            item.w=400;
                            item.h=400;
                            this.list.push(item);
                        });
                    } else {
                        Toast('网络较差，请稍候再试')
                    }
                })
            },

        },
        components: {
            "comment-Box": comment
        }
    }
</script>


<style lang="less" scoped>
.photoList-container {
    padding: 3px;
    h3 {
        color: #5bc0de;
        text-align: center;
        margin: 15px 0;
    }
    .time {
        font-size: 13px;
        text-align: right;
    }
    .content {
        line-height: 30px;
        font-size: 13px;
        margin: 0 10px;
    }
    .imgList {
        img {
            margin-left: 5px;
            width:117px;
            box-shadow: 0 0 2px #000;
        }
    }




}
</style>